import useUserInfoStore from '@/stores/userInfo'
import { Role, Status } from '@/types/constants';
import useDarkModeStore from '@/stores/darkMode'

const userInfoStore = useUserInfoStore()
const darkModeStore = useDarkModeStore()

export const getStatus = (): Status => {
  const userInfo = userInfoStore.userInfo;
  if (userInfo === null) return Status.NOT_LOGIN
  return userInfo.role === Role.PASSENGER ? Status.PASSENGER : Status.DRIVER
}

export const switchNavBarTheme = () => {
  const dark = darkModeStore.isDark
  uni.setNavigationBarColor({
    frontColor: dark ? '#ffffff' : '#000000',
    backgroundColor: dark ? '#1B1B1B' : '#ffffff',
  })
}

export const switchTabBarTheme = () => {
  const dark = darkModeStore.isDark
  uni.setTabBarStyle({
    color: dark ? '#ffffff' : '#000000',
    backgroundColor: dark ? '#1B1B1B' : "#ffffff",
  })
  uni.setTabBarItem({
    index: 0,
    iconPath: dark ? 'static/tabs/home_dark.png' : 'static/tabs/home.png',
  })
  uni.setTabBarItem({
    index: 1,
    iconPath: dark ? 'static/tabs/order_dark.png' : 'static/tabs/order.png',
  })
  uni.setTabBarItem({
    index: 2,
    iconPath: dark ? 'static/tabs/my_dark.png' : 'static/tabs/my.png',
  })
}
